package com.jt.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@PropertySource("classpath:/properties\\redis.properties")
public class RedisController {
   // 1.通过yml赋值
@Value("${redis.host}")
private String host;            //="127.0.0.1";
@Value("${redis.port}")
private int port;                //=6379;


//通过pro赋值
    @Value("${redis2.host}")
    private String host2;
    @Value("${redis2.port}")
    private int port2;



    @RequestMapping("/getNode")
    public String getNode(){

        return "yml取值方式："+ host+":"+port+ "\n" +
                "pro取值方式"+host2+":"+port2;

    }
}
